import {
	objDeepCopy
} from "@/assets/js/common.js";
import commonObject from "@/assets/js/xm.js";
let Controller = {
	methods: {
		init() {
			this.getlist(this, 3);
		},
		//获取列表数据
		getlist(that, level, page) {
			var apiTest = this.apiTest;
			page = page || this.Model.page;
			this.$ajax({
				method: 'post',
				// url: '/api/saleGoodsLevel/list',
				url:apiTest+'/sale/saleGoodsLevel/list',
				data: {
					condition: {
						level: level,
					},
					pageSize: page.pageSize,
					pageIndex: page.pageIndex
				}
			}).then((res) => {
				console.log(res);
				that.Model.tableData = [];
				var data = res.data;

				if (data.status == 200) {
					var obj = {};
					var pagination = commonObject.paginationFunction(data.result);
					that.Model.paginationObject = objDeepCopy(pagination);
					var result = data.result.result;
					for (var i = 0; i < result.length; i++) {
						obj = objDeepCopy(result[i]);
						if (level == 1) {
							obj.level = '一级'
						} else if (level == 2) {
							obj.level = '二级'
						} else {
							obj.level = '三级'
						}
						//
						that.Model.tableData.push(obj);
					}

				} else {

				}
			});
		},
		handleSizeChange(val) {
			var page = this.Model.page;
			page.pageSize = val;
			this.getlist(this, 3, page);
		},
		handleCurrentChange(val) {
			var page = this.Model.page;
			page.pageIndex = val;
			this.getlist(this, 3, page);
		},

	}
}
export default Controller;
